﻿using B.S.DataBase.MyProject.Domain.患者移动端;
using B.S.DataBase.MyProject.ErrorCode;
using B.S.DataBase.MyProject.Infrastructure;
using B.S.DataBase.MyProject.Infrastructure.Interface;
using MediatR;
<<<<<<<< HEAD:MedicalPCTerminal.Read.API/Appcation/CommandHandlers/PatientMovementCommandHandler/MeCommandHandler.cs
using MedicalPCTerminal.Read.API.Appcation.Commands.PatientMovementCommand;
using SqlSugar;

namespace MedicalPCTerminal.Read.API.Appcation.CommandHandlers.PatientMovementCommandHandler
========
using SqlSugar;

namespace MedicalPCTerminal.Read.API.Appcation.Commands.患者移动端
>>>>>>>> parent of fe317f5 (修改命名空间):MedicalPCTerminal.Read.API/Appcation/CommandHandlers/患者移动端/MeCommandHandler.cs
{
    /// <summary>
    /// 处理我的显示命令
    /// </summary>
    public class MeCommandHandler : IRequestHandler<MeCommand, APIResult<List<Me>>>
    {
        private readonly SqlSugarContext sqlSugar;

        /// <summary>
        /// 构造方法
        /// </summary>
        /// <param name="meRepository">仓储</param>
        public MeCommandHandler(SqlSugarContext sqlSugar)
        {
            this.sqlSugar = sqlSugar;
        }
        /// <summary>
        /// 处理命令
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<APIResult<List<Me>>> Handle(MeCommand request, CancellationToken cancellationToken)
        {
            APIResult<List<Me>> result=new APIResult<List<Me>>();
            try
            {
                var entity = sqlSugar.db.Queryable<Me>().Where(x => x.MId == request.MId).ToList();
                if (entity != null)
                {
                    result.Code = APIEnum.查询成功;
                    result.Msg = APIEnum.查询成功.ToString();
                    result.data = entity.ToList();
                }
                else
                {
                    result.Code = APIEnum.查询失败;
                    result.Msg = APIEnum.查询失败.ToString();
                }
               
            }
            catch (Exception)
            {

                throw;
            }
            return await Task.FromResult(result);
        }
    }
}
